package cn.jlonely.xyhx.app.service.impl;

import cn.jlonely.xyhx.app.mapper.AppRankingMapper;
import cn.jlonely.xyhx.app.service.AppRankingService;
import cn.jlonely.xyhx.pojo.Comments;
import cn.jlonely.xyhx.pojo.Ranking;
import cn.jlonely.xyhx.pojo.vo.CommentsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AppRankingServiceImpl implements AppRankingService {
    @Autowired
    private AppRankingMapper appRankingMapper;

    /**
     * 获取排行榜
     *
     * @param userId
     * @param topic
     * @param id
     * @return
     */
    @Override
    public List<Ranking> getRankingInfoAll(Integer userId, String topic, Integer id) {

        return appRankingMapper.getRankingInfoAll(userId,topic, id);
    }

    /**
     * 创建收藏
     * @param userId
     * @param rankingId
     */
    @Override
    public void createFavorite(Integer userId, Integer rankingId) {
        appRankingMapper.createFavorite(userId,rankingId);
    }

    /**
     * 删除收藏
     * @param userId
     * @param rankingId
     */

    @Override
    public void deleteFavorite(Integer userId, Integer rankingId) {
        appRankingMapper.deleteFavorite(userId,rankingId);
    }

    /**
     * 查询所有收藏
     * @param userId
     * @return
     */
    @Override
    public List<Ranking> getFavoriteAll(Integer userId) {
        return appRankingMapper.getFavoriteAll(userId);
    }

    /**
     * 查询所有参与投票记录
     * @param userId
     * @return
     */
    @Override
    public List<Ranking> getHistoryVitoAll(Integer userId) {
        return appRankingMapper.getHistoryVitoAll(userId);
    }

    /**
     * 查询所有评论
     * @param rankingId
     * @return
     */
    @Override
    public List<Comments> getCommentsAll(Integer rankingId) {
      List<Comments> comments=  appRankingMapper.getCommentsAll(rankingId);
      return  comments;

    }

    /**
     * 创建评论
     * @param comments
     */
    @Override
    public void createComments(Comments comments) {
        appRankingMapper.createComments(comments);
    }

    /**
     * 查看历史评论
     * @param userId
     * @return
     */

    @Override
    public List<CommentsVo> getHistoryComments(Integer userId) {
        return appRankingMapper.getHistoryComments(userId);
    }

}
